function MarkerPicker(xpoint,ypoint){

	//默认可选参数
	var dconfig={
		"element":"",
		"width":500,
		"height":410,
		"isCenter":true,
		"isCityControl":true,
		"isFullScreen":true
	};
	var temp=this;
	//尺寸限制
	if(dconfig.width<500){
		dconfig.width=500;
	};
	if(dconfig.height<410){
		dconfig.height=410;
	};
	var time=new Date().getTime();
	var baidumap;
	var tempx;
	var tempy;
	var pannel=document.createElement("div");
	$(pannel).attr('id','MapBaidu'+time);
	pannel.style.cssText="background:#FFF;display:inline-block;";
	pannel.innerHTML = '<div id="con'+time+'" style="width:'+(dconfig.width)+'px;height:'+(dconfig.height)+'px;position:relative;overflow:hidden;font-size:12px;">'+
							//菜单栏
							'<div style="height:28px;">'+
								'<div style="width:11px;height:27px;float:left;background:url(/Public/Js/map/images/tit_left.jpg);"></div>'+
								'<div id="main'+time+'" style="width:'+(dconfig.width-22)+'px;height:27px;float:left;background:url(/Public/Js/map/images/tit_main.jpg);overflow:hidden;">'+
									'<div id="btnClose'+time+'" style="width:14px;height:28px;float:right;background:url(/Public/Js/map/images/close.gif) no-repeat center center;cursor:pointer;"></div>'+
									'<div id="btnFull'+time+'" style="width:14px;height:28px;margin-right:8px;float:right;background:url(/Public/Js/map/images/fullscreen.gif) no-repeat center center;cursor:pointer;"></div>'+
									'<div style="width:232px;line-height:28px;float:left;color:#0B7ECE;">1.选择位置&nbsp;&gt;&nbsp;2.标注位置&nbsp;&gt;&nbsp;3.保存位置</div>'+																									
									'<div id="nosave'+time+'" style="width:39px;line-height:28px;float:left;color:#f00;display:none;">未保存</div>'+
								'</div>'+
								'<div style="width:11px;height:27px;float:left;background:url(/Public/Js/map/images/tit_right.jpg);"></div>'+																	
							'</div>'+
							//地图容器
							'<div id="bo'+time+'" style="height:'+(dconfig.height-80)+'px;border:1px solid #999;border-bottom:0px none;">'+
								'<div id="baidumap" style="height:'+(dconfig.height-90)+'px;padding:5px;"></div>'+
							'</div>'+
							//底部
							'<div style="height:38px;padding-top:12px;background:url(/Public/Js/map/images/bottom.jpg);border:1px solid #999;border-top:0px none;position:relative;">'+
								'<div id="pointxy'+time+'" style="width:200px;line-height:28px;position:absolute;top:12px;left:10px;text-align:left;"></div>'+								
								'<div id="save'+time+'" style="width:106px;line-height:28px;position:absolute;top:12px;right:149px;text-align:center;cursor:pointer;background:url(/Public/Js/map/images/btn_marker.png)">保存</div>'+
								'<div id="cancel'+time+'" style="width:106px;line-height:28px;position:absolute;top:12px;right:30px;text-align:center;cursor:pointer;background:url(/Public/Js/map/images/btn_marker.png)">取消</div>'+
								'<div id="resize'+time+'" style="width:12px;height:12px;position:absolute;bottom:0px;right:0px;cursor:se-resize;background:url(/Public/Js/map/images/resize.gif);"></div>'+
							'</div>'+
							//修复IE6下下拉列表的bug
							'<iframe id="ifra'+time+'" style="width:'+(dconfig.width+1)+'px;height:'+(dconfig.height-2)+'px;position:absolute;top:-2px;left:-2px;z-index:-1;"></iframe>'+
						'</div>';
	$("body").append(pannel);
	setCenter();
	px = $('#'+ypoint).val();
	px = px?px:$('#'+ypoint).text();
	
	py = $('#'+xpoint).val();
	py = py?py:$('#'+xpoint).text();
	baiduMap(px,py);
	//关闭窗口
	$('#btnClose'+time).live('click', function() {
		$('#MapBaidu'+time).remove();
	});
	//保存操作
	$('#save'+time).live('click', function() {
		pointxy = $('#pointxy'+time).html();
		point = pointxy.split(',');
		$('#'+xpoint).val(point[0]);
		$('#'+ypoint).val(point[1]);
		$('#MapBaidu'+time).remove();
	});
	//取消按钮
	$('#cancel'+time).live('click', function() {
		$('#MapBaidu'+time).remove();
	});
	//最大化或还原窗口
	$('#btnFull'+time).live('click', function(e) {
		Y = $(this).scrollTop();
		if($('#MapBaidu'+time).attr('ismax')=='true'){
			resize(500,400,Y);
			setCenter();
			$('#MapBaidu'+time).attr('ismax','');
		}else{
			resize('','',Y);
			$('#MapBaidu'+time).attr('ismax','true');
		}
	});
	//拖动窗口
	var flag=true;
	$('#main'+time).live('mousedown', function(e) {
		stopPropagation(e);
		$(this).css('cursor','move');
		offsetLeft=e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)-parseInt(pannel.style.left);
		offsetTop=e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)-parseInt(pannel.style.top);
		if(flag==true){
			flag=false;
			$(this).mousemove(function(e){
				drag(e);
			});
		}
		$(this).mouseup(function(e){
			$(this).css('cursor','default');
			flag=true;
			$(this).unbind('mousemove');
		});
	});
	function resize(w,h,Y){
		h = h?h:$(window).height();
		w = w?w:$(window).width();
		$('#MapBaidu'+time).css({'width':w+'px','top':Y+'px','left':'0px',});
		$('#con'+time).css({'width':w+'px','height':h+'px',});
		$('#bo'+time).css({
			'width':(w-2)+'px',
			'height':(h-80)+'px',
		});
		$('#baidumap').css({
			'height':(h-90)+'px',
		});
		$('#main'+time).css({
			'width':(w-22)+'px',
		});
	}
	//window.onresize=setPosition;
	function setCenter(){
		var w=document.documentElement.offsetWidth||document.body.offsetWidth;
		var h=document.documentElement.clientHeight||document.body.clientHeight;
		var top=document.documentElement.scrollTop||document.body.scrollTop;
		var left=document.documentElement.scrollLeft||document.body.scrollLeft;
		$(pannel).css('position','absolute');
		$(pannel).css('z-index','9999');
		$(pannel).css('top',(h-pannel.offsetHeight)/2+top+"px");
		$(pannel).css('left',(w-pannel.offsetWidth)/2+left+"px");
	};
	function drag(e){
		stopPropagation(e);
		var x=e.clientX;
		var y=e.clientY;
		var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
		var scrollLeft=document.documentElement.scrollLeft||document.body.scrollLeft;
		pannel.style.left=x+scrollLeft-offsetLeft+"px";
		pannel.style.top=y+scrollTop-offsetTop+"px";
	};
	function pannelResize(e){
		stopPropagation(e);
		var left=e.clientX-startLeft;
		var top=e.clientY-startTop;
		var con=document.getElementById("con"+time);
		var main=document.getElementById("main"+time);
		var bo=document.getElementById("bo"+time);
		var mapC=document.getElementById("map"+time);
		var ifra=document.getElementById("ifra"+time);
		if(width+left<500||height+top<410){return;};
		con.style.width=(width+left)+"px";
		con.style.height=(height+top+8)+"px";
		main.style.width=(width+left-22)+"px";
		bo.style.height=(height+top-80)+"px";
		mapC.style.height=(height+top-90)+"px";		
		ifra.style.width=(width+left+1)+"px";
		ifra.style.height=(height+top-2)+"px";
		map.notifyResize();
	};
	function stopPropagation(e){
		if(e.stopPropagation){
			e.stopPropagation();
			e.preventDefault();
		}else{
			e.cancelBubble=true;
		}
	};
	function baiduMap(px,py) {
		loading('加载地图中...');
		jQuery.getScript("http://api0.map.bdimg.com/getscript?v=2.0&ak=l8RoARlYT855XCZklKalvmKb&services=&t="+window.BMap_loadScriptTime, function(){
			px = px?px:24.489635;
			py = py?py:118.037998;
			baidumap = new BMap.Map('baidumap');
			baidumap.centerAndZoom(new BMap.Point(py,px), 14);
			baidumap.addControl(new BMap.NavigationControl());
			//baidumap.addControl(new BMap.MapTypeControl({mapTypes: [BMAP_NORMAL_MAP,BMAP_HYBRID_MAP]}));
			//baidumap.addControl(new BMap.MapTypeControl({anchor: BMAP_ANCHOR_TOP_LEFT}));
			var pt = new BMap.Point(py,px);
			var marker = new BMap.Marker(pt);  // 创建标注
			baidumap.clearOverlays();
			baidumap.addOverlay(marker); // 将标注添加到地图中
			baidumap.enableScrollWheelZoom();
			baidumap.setDefaultCursor('default');
			tempx = py;
			tempy = px;
			baidumap.addEventListener("click", function(e){//绑定事件
				var pt = new BMap.Point(e.point.lng,e.point.lat);
	//			var myIcon = new BMap.Icon("/Public/images/pin_3.gif", new BMap.Size(39,39));
	//			var marker = new BMap.Marker(pt,{icon:myIcon});  // 创建标注
				var marker = new BMap.Marker(pt);  // 创建标注
				baidumap.clearOverlays();
				baidumap.addOverlay(marker); // 将标注添加到地图中
				$('#pointxy'+time).html(e.point.lng+','+e.point.lat);
				tempx = e.point.lng;
				tempy = e.point.lat;
				panTo(tempx,tempy);
			});
			removeLoading();
		});
	}
	function panTo(x,y){
		baidumap.panTo(new BMap.Point(x,y));
	}
}
